﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace li4_staffsched.Camada_de_Dados
{
    class conexaoDB
    {
        private void button1_Click(object sender, EventArgs e)
        {
            string connetionString = null;
            SqlConnection cnn ;
			connetionString = "Data Source=RICARDO-PC\\SQLLI4,1433;Initial Catalog=db_staffsched;User ID=li4staff;Password=li4g2";
            
            
            
            cnn = new SqlConnection(connetionString);
            try
            {
                cnn.Open();
                MessageBox.Show ("Connection Open ! ");
                //cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }

            SqlCommand sqlComm = new SqlCommand("SELECT * FROM Cliente", cnn);
            SqlDataReader r = sqlComm.ExecuteReader();
            while (r.Read())
            {
                string username = (string)r["id_cliente"];
                string userID = (string)r["rua"];
                MessageBox.Show(username + "(" + userID + ")");
            }
        }
    }
    }
}
